import org.apache.spark.{SparkConf, SparkContext}

object SimpleRDDJoins {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setAppName("SimpleJoins").setMaster("local[*]")
    val sc = new SparkContext(conf)

    val rdd1 = sc.parallelize(Seq((1, "A"), (2, "B")))
    val rdd2 = sc.parallelize(Seq((1, "X"), (3, "Y")))

    rdd1.join(rdd2).collect().foreach(println)

    rdd1.leftOuterJoin(rdd2).collect().foreach(println)
    
    rdd1.rightOuterJoin(rdd2).collect().foreach(println)

    rdd1.fullOuterJoin(rdd2).collect().foreach(println)

    sc.stop()
  }
}